package GoodsService

import (
	"context"
	"database/sql"
	"gdshop-back-end-go/client-api/app/response/GoodsResp"
	toolsDb "gdshop-back-end-go/common/db"
	"github.com/gogf/gf/frame/g"
)

func GetGoodsModelRaw(ctx context.Context, goodsId int) *GoodsResp.Details {
	goodsModel := GoodsResp.Details{}
	err := toolsDb.GetUnSafaTableAddDeleteWhere(ctx, "goods").Where("id",
		goodsId).Struct(&goodsModel)
	if err != nil {
		if err != sql.ErrNoRows {
			g.Log().Async().Error("GetGoodsModelRaw " + err.Error())
			return nil
		}
	}
	if goodsModel.Id != uint(goodsId) {
		g.Log().Async().Error("GetGoodsModelRaw 找不到数据")
		return nil
	}
	return &goodsModel
}
